﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.Management;
using System.Threading;
using System.Timers;

namespace HoloPenXservice
{
    public partial class Service1 : ServiceBase
    {
        //protected System.Timers.Timer t;
        public Service1()
        {
            InitializeComponent();
            
        }

        //protected override void OnStart(string[] args)
        //{
        //    base.OnStart(args);
        //}

        //protected override void OnStop()
        //{
        //    base.OnStop();
        //}

        protected override void OnContinue()
        {
            //ObjectQuery winQuery = new ObjectQuery("SELECT * FROM Win32_LogicalMemoryConfiguration");

            //ManagementObjectSearcher searcher = new ManagementObjectSearcher(winQuery);

            //foreach (ManagementObject item in searcher.Get())
            //{
            //    EventLog.WriteEntry("Total Space = " + item["TotalPageFileSpace"]);
            //    EventLog.WriteEntry("Total Physical Memory = " + item["TotalPhysicalMemory"]);
            //    EventLog.WriteEntry("Total Virtual Memory = " + item["TotalVirtualMemory"]);
            //    EventLog.WriteEntry("Available Virtual Memory = " + item["AvailableVirtualMemory"]);
            //}
            PerformanceCounter perfcount = new PerformanceCounter();
            perfcount.CategoryName = "Processor";
            perfcount.CounterName = "% Processor Time";
            perfcount.InstanceName = "_Total";
            PerformanceCounter ramCount = new PerformanceCounter("Memory", "Available MBytes");
            EventLog.WriteEntry("cpuUse:" + perfcount.NextValue() + "%");
            EventLog.WriteEntry("ramUse:" + ramCount.NextValue() + "Mb");
            base.OnContinue();
            
        }
    }
}
